<?php
ini_set("soap.wsdl_cache_enabled", 0);

// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/models'),
realpath(APPLICATION_PATH . '/models/om'),
realpath(APPLICATION_PATH . '/models/map'),
realpath(APPLICATION_PATH . '/models/empeval'),
realpath(APPLICATION_PATH . '/models/empeval/om'),
realpath(APPLICATION_PATH . '/models/empeval/map'),
realpath(APPLICATION_PATH . '/models/damages'),
realpath(APPLICATION_PATH . '/models/damages/om'),
realpath(APPLICATION_PATH . '/models/damages/map'),
realpath(APPLICATION_PATH . '/models/rcp'),
realpath(APPLICATION_PATH . '/models/rcp/om'),
realpath(APPLICATION_PATH . '/models/rcp/map'),
realpath(APPLICATION_PATH . '/models/lp'),
realpath(APPLICATION_PATH . '/models/lp/om'),
realpath(APPLICATION_PATH . '/models/lp/map'),
realpath(APPLICATION_PATH . '/config'),
realpath(APPLICATION_PATH . '/../library/Propel/runtime/lib'),
realpath(APPLICATION_PATH . '/../library/PHPExcel'),
realpath(APPLICATION_PATH . '/../library/PhpMailer'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
		APPLICATION_ENV,
		APPLICATION_PATH . '/configs/application.ini'
);

$loader = new Zend_Loader_Autoloader_Resource(array(
		'namespace' => 'Application_',
		'basePath'  => realpath(APPLICATION_PATH . '/'),
));

// function errorHandle($level, $errstr, $errfile, $errline) {
// 	switch ($level) {
// 		case E_NOTICE:
// 		case E_USER_NOTICE:
// 			new App_Exception_Php(App_Exception_Php::NOTICE, $level, $errstr, $errfile, $errline);
// 			break;
// 		case E_WARNING:
// 		case E_USER_WARNING:
// 			new App_Exception_Php(App_Exception_Php::WARNING, $level, $errstr, $errfile, $errline);
// 			break;
// 		case E_ERROR:
// 		case E_USER_ERROR:
// 			new App_Exception_Php(App_Exception_Php::ERROR, $level, $errstr, $errfile, $errline);
// 			break;
// 		case E_PARSE:
// 			new App_Exception_Php(App_Exception_Php::PARSE, $level, $errstr, $errfile, $errline);
// 			break;
// 		default:
// 			new App_Exception_Php(App_Exception_Php::UNDEFINED, $level, $errstr, $errfile, $errline);
// 			break;
// 	}
// }
// set_error_handler('errorHandle');
// register_shutdown_function(function() {
// 	$error = error_get_last();
// 	//var_dump(debug_backtrace());die;
// 	if ($error !== null) {
// 		errorHandle($error['type'], $error['message'], $error['file'], $error['line']);
// 	}
// });
$application->bootstrap()->run();
